<template>
  <div class="user-info">
    <el-dropdown>
      <span class="el-dropdown-link">
        <el-avatar size="small" :src="circleUrl"></el-avatar>
        <div class="my-info">
          <span>{{ username }}</span>
          <span>{{ username }}</span>
        </div>
        <el-icon class="el-icon--right">
          <arrow-down />
        </el-icon>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item>个人信息</el-dropdown-item>
          <el-dropdown-item>系统管理</el-dropdown-item>
          <el-dropdown-item>退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from 'vue'
import { useStore } from '@/store'
export default defineComponent({
  setup() {
    const circleUrl = ref<string>()
    circleUrl.value = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
    const store = useStore()
    // console.log(JSON.stringify(store.state.loginModule.userInfo))
    const username = computed(() => store.state.loginModule.userInfo.name)
    return { circleUrl, username }
  }
})
</script>

<style scoped lang="less">
.user-info {
  .el-dropdown-link {
    cursor: pointer;
    display: flex;
    align-items: center;
    .my-info {
      display: flex;
      flex-direction: row;
    }
  }
}
</style>
